import {createApp} from 'vue'
import App from './App.vue'
import router from './router/index.js'
import store from './store/index.js'
import './style.css'
import i18n from './language/index'
import {ElMessage} from 'element-plus'
import 'element-plus/dist/index.css'
import 'virtual:svg-icons-register';
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import {log} from "@/util/Log.js"
import Bus from "@/util/Bus.js";
import VueMarkdownEditor from '@kangc/v-md-editor';
import '@kangc/v-md-editor/lib/style/base-editor.css';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';
import 'highlight.js/styles/monokai.css';
import socket from "@/util/WebSocket.js";
import ElementPlusX from 'vue-element-plus-x';


// 全局异常
const errorHandler = (err, vm, info) => {
    // 在这里可以添加额外的日志记录、通知或错误报告
    log.error(`Error: ${err.toString()} \nInfo: ${info}`);
};

const app = createApp(App)

app.config.errorHandler = errorHandler;
app.use(router)
app.use(store)
app.use(i18n)
app.provide('socket',socket())
app.provide('log',log)
app.provide('bus', Bus)
app.provide('$t', i18n.global.t)
app.provide('message', ElMessage)
app.use(VueMarkdownEditor);
app.use(ElementPlusX);


for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

app.mount('#app')
